package com.casic.ops.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.casic.ops.annotation.RestWrapper;
import com.casic.ops.dao.SonarqubeInfoDAO;
import com.casic.ops.entity.domain.SonarqubeDashboardBean;
import com.casic.ops.entity.vo.DashBordIconVO;
import com.casic.ops.entity.vo.pipeline.response.Response;
import com.casic.ops.service.api.pipeline.PipelineLoggerService;
import com.casic.ops.service.api.pipeline.PipelineService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @ClassName ops
 * @Description 首页接口
 * @Author mianbin
 * @Date 2022/6/28 17:07
 * @Version 1.0
 **/
@RequestMapping("/ops/api/dashboard")
@RestController
@RestWrapper
public class DashboardController {
    @Resource
    PipelineService pipelineService;
    @Resource
    PipelineLoggerService pipelineLoggerService;
    @Resource
    SonarqubeInfoDAO sonarqubeInfoDAO;

    @RequestMapping("/recently/history")
    public Response getHistory() {
        return pipelineLoggerService.getRecentlyHistory();
    }

    @RequestMapping("/recently/pipeline")
    public Response getApplication() {
        return pipelineService.getRecentlyPipeline();
    }
//    //先弄个假数据，流水线的节点没有现成的对应图标
//    @GetMapping("/recently/icon")
//    public List<DashBordIconVO> getNodeIcon(){
//        List<DashBordIconVO> iconVOS=new ArrayList<>();
//        return iconVOS;
//    }
    @GetMapping("sonarqube")
    public List<SonarqubeDashboardBean> getSonarqube() {
        /*前端就返回最近10个项目即可,按时间排序,目前未排序*/
        Page<SonarqubeDashboardBean> page = new Page<>(1, 10, 10);
        return sonarqubeInfoDAO.selectPage(page, null).getRecords();
    }
}
